package com.zhangqie.dnui.demo2;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.zhangqie.dnui.R;
import com.zhangqie.dnui.demo2.demo1.Demo1;
import com.zhangqie.dnui.demo2.demo2.Demo2;

public class RecyclerViewActivity extends AppCompatActivity {


    private String[] string = new String[]{"RecyclerView1","RecyclerView2-分割线","RecyclerView3-分割线"};

    private ListView listView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView(){
        listView = findViewById(R.id.listivew);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,string);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                showIndex(position);
            }
        });
    }


    private void showIndex(int index){
        switch (index){
                case 0:
                    startActivity(new Intent(RecyclerViewActivity.this, Demo1.class));
                    break;
                case 1:
                    startActivity(new Intent(RecyclerViewActivity.this, Demo2.class));
                    break;
                case 2:
                    startActivity(new Intent(RecyclerViewActivity.this, com.zhangqie.dnui.demo2.demo3.MainActivity.class));
                    break;
                case 3:
                    startActivity(new Intent(RecyclerViewActivity.this, Demo1.class));
                    break;
            }

        }


}
